<?php
session_start();
include_once("imageResize.php");
 if(isset($_POST['uplod_post']))
 {
if (isset($_FILES['image']) && $_FILES['image']['name']!='') {
	$ftmp = $_FILES['image']['tmp_name'];
	$oname = $_FILES['image']['name'];
	$ex=explode(".",$_FILES['image']['name']);
	$a=rand(1,200000);
	$file_ex=count($ex);
	
	$date_filename="advertise_".date("ymdhms").$a.".".$ex[$file_ex-1];
	$fname = "advertise/". $date_filename;
	$_hidden_imagefile_= $date_filename;

	if(move_uploaded_file($ftmp, $fname)){
	$image_val='';//'<iframe src="advertise_photo.php" frameborder="0" scrolling="no" id="iframid"  height="40px"></iframe>';
		@imageResize($_hidden_imagefile_,'advertise','advertise_thumb','75','75');
		//@imageResize($_hidden_imagefile_,'advertise','advertise','80','110');
		@imageResize($_hidden_imagefile_,'advertise','advertise','100','137');
	$thumb_="advertise_thumb/".$_hidden_imagefile_;
	$val_name="imagefileHIDDEn";
	//$width_height=widthheight($_hidden_imagefile_,'coolimage','240','180');
	//$widtharra=explode("alada123",$width_height);
	//$width_width=100;
	//$height_height=100;
	}}
		
	 
	echo "<script>
		var par = window.parent.document;
		
		var images = par.getElementById('images_container');
		
		var imgdiv = images.getElementsByTagName('div')[".(int)$_POST['imgnum']."];
			var imagename = par.getElementById('imagefileHIDDEn');
			imagename.value='".$_hidden_imagefile_."';
			
			
			
		var image = imgdiv.getElementsByTagName('img')[0];
		imgdiv.removeChild(image);
		var image_new = par.createElement('img');
		image_new.src = '".$thumb_."';
			
		imgdiv.appendChild(image_new);
		if(document.getElementById('inPUTbuTTOn') != null)
		{
		document.getElementById('inPUTbuTTOn').innerHTML='<input type=\"button\" name=\"contiNue\" id=\"contiNue\" value=\"Continue\" onclick=\"return CheckValidationFORstep1();\" />';
		}

		</script>";	#exit();
	
}
?><head>
<style>

iframe.hidden {

	visibility: visible;

	width:0px;

	height:0px;

}

iframe.visible {

    visibility:visible;

	width:0px;

	height:auto;

}


</style>

<script language="javascript">
/*function terms()
{
  window.parent.location="terms.php";
}*/

function upload(){

var fcheck='';
if(document.iform.image.value!='')
{
if(document.iform.image.value!='')
 fcheck=document.iform.image.value;

}

if(fcheck.indexOf(".jpg")==-1 && fcheck.indexOf(".jpeg")==-1 && fcheck.indexOf(".JPG")==-1 && fcheck.indexOf(".JPEG")==-1 &&fcheck.indexOf(".png")==-1 && fcheck.indexOf(".PNG")==-1  && fcheck.indexOf(".gif")==-1 && fcheck.indexOf(".GIF")==-1)
{
alert("please upload jpg,png,gif");
return false;
}
	var par = window.parent.document;

	// hide old iframe
	var iframes = par.getElementsByTagName('iframe');
	var iframe = iframes[iframes.length - 1];
	iframe.className = 'hidden';
	
	// add image progress
	var images = par.getElementById('images_container');
	images.innerHTML='';
	var new_div = par.createElement('div');
	var new_img = par.createElement('img');
	new_img.src = 'images/indicator.gif';
	new_img.className = 'loaded1';
	new_div.appendChild(new_img);
	images.appendChild(new_div);
	//alert("sadasdasdasd");
	//alert(document.getElementById("inPUTbuTTOn"));
	/********************************sandip bhattacharjee******************************/
	if(document.getElementById("inPUTbuTTOn") != null)
	{
		document.getElementById("inPUTbuTTOn").innerHTML='<img src="images/indicator_blue_small.gif" border="0"  />';
	}
	/********************************sandip bhattacharjee******************************/
	// send
	var imgnum = images.getElementsByTagName('div').length - 1;
	document.iform.imgnum.value =imgnum;
	document.iform.submit();

}

</script>


<!--<link href="css/upload_file.css" rel="StyleSheet" type="text/css"/>-->
</head>
<body>
<form name="iform" class="example" action="" method="post" enctype="multipart/form-data">
							 <input type="file" name="image" size="16" onChange="return upload();" onKeyUp="return upload();" /><br>
						   <!-- <div class="md_rt2_txt-btn">Fetch</div>-->
			                <input type="hidden" name="uplod_post" value="">
                            <input type="hidden" name="imgnum" />
<!--<a onClick="return upload();" style="cursor:pointer" id="orenge_bottonlink">upload</a>-->
</form>
</body>